﻿Public Class Form1
    Private mSpk As AgentObjects.IAgentCtlCharacter
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            'Dim Myagent As New AgentObjects.Agent

            AxAgent1.Characters.Load(Me.ComboBox1.Text, "C:\WINDOWS\msagent\chars\" & Me.ComboBox1.Text & ".acs")

            ' AxAgent1.Characters.Load("rover", "C:\WINDOWS\msagent\chars\" & Me.ComboBox1.Text & ".acs")
            mSpk = AxAgent1.Characters(Me.ComboBox1.Text)
            'Dim Enume As IEnumerator = AxAgent1.Characters.Character(mSpk.Name).AnimationNames.GetEnumerator()

            Dim Enume As IEnumerator = AxAgent1.Characters.Character(mSpk.Name).AnimationNames.GetEnumerator()

            While Enume.MoveNext
                ComboBox2.Items.Add(Enume.Current)
            End While

        Catch ex As Exception
            MsgBox(ex.Message())
        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        mSpk.Show(0)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        mSpk.Hide()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'Stop the previous action to start new one
        mSpk.Stop()
        'Play the new action
        mSpk.Play(ComboBox2.Text)
        'Turn to rest position
        mSpk.Play("RestPose")
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        mSpk.StopAll()
        AxAgent1.Characters.Load(Me.ComboBox1.Text, "C:\WINDOWS\msagent\chars\" & Me.ComboBox1.Text & ".acs")
        mSpk = AxAgent1.Characters(Me.ComboBox1.Text)

        Dim Enume As IEnumerator = AxAgent1.Characters.Character(mSpk.Name).AnimationNames.GetEnumerator()
        ComboBox2.Items.Clear()
        While Enume.MoveNext
            ComboBox2.Items.Add(Enume.Current)
        End While

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        'Stop the previous action to start new one
        mSpk.Stop()
        'Speak the text
        mSpk.Speak(TextBox1.Text)
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        mSpk.Stop()
        'Let the character to move to the position of current mouse pointer
        mSpk.MoveTo(Convert.ToInt16(Cursor.Position.X - 60), Convert.ToInt16(Cursor.Position.Y - 60))
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub
End Class